{% load ts_extras %}

<li {% if tp.name == request.session.ts_program.tp.name %}
        class="active"
    {% endif %}
    >
    <div class="collapsed">
        <a class="expand" href="#" title="expand" ></a>
        <a class="collap" href="#" title="collap" ></a>
        <a title="Transsys program {{tp.name}}" href="{% url tsworkbench.views.ts.viewTP tp.name|escapeUrl %}?with_sgx=1">{{tp.name}}</a>
        <a id="{% url tsworkbench.views.sgx.delTargetTranssysProgram sgxp.name|escapeUrl tp.name|escapeUrl %}?with_sgx=1" rev="transsys program from target transsys program list" class="delete" href="#" title="delete" ></a>
    </div>
    <div class="expanded">
        <!-- Factor listing -->
        <div class="treeview-lv1">
            <div class="collapsed ">
                <span>Factor list</span>
                <a class="expand" href="#" title="expand" ></a>
                <a class="collap" href="#" title="collap" ></a>
            </div>
            <div class="expanded">
            {% if tp.factor_list %}
            <ul class="list-lv2">
            {% for f in tp.factor_list %}
                <li>
                    <div class="collapsed">
                        <a title="Factor {{f.name}}" href="{% url tsworkbench.views.ts.editFactor tp.name|escapeUrl f.name %}?with_sgx=1" >{{f.name}}</a>
                        <a class="expand" href="#" title="expand" ></a>
                        <a class="collap" href="#" title="collap" ></a>
                        <a id="{% url tsworkbench.views.ts.delFactor tp.name|escapeUrl f.name %}?with_sgx=1" rev="factor" class="delete" href="#" title="delete" ></a>
                    </div>
                    <div class="expanded">
                    <ul>
                        <li>Decay: {{f.decay_expression}}</li>
                        <li>Diffusibility: {{f.diffusibility_expression}}</li>
                    </ul>
                    </div>
                </li>
            {% endfor%}
            </ul>
            {%else%}
            <p>No factors</p>
            {%endif%}
            </div>
        </div>
        <!-- Gene listing -->
        <div class="treeview-lv1">
            <div class="collapsed">
                <span>Gene list</span>
                <a class="expand" href="#" title="expand" ></a>
                <a class="collap" href="#" title="collap" ></a>
            </div>
            <div class="expanded">
        {% if tp.gene_list %}
            <ul class="list-lv2">
            {% for g in tp.gene_list %}
                <li>
                    <div class="collapsed">
                        <a title="Gene {{g.name}}" href="{% url tsworkbench.views.ts.editGene tp.name|escapeUrl g.name %}?with_sgx=1">{{g.name}}</a>
                        <a class="expand" href="#" title="expand" ></a>
                        <a class="collap" href="#" title="collap" ></a>
                        <a id="{% url tsworkbench.views.ts.delGene tp.name|escapeUrl g.name %}?with_sgx=1" rev="gene" class="delete" href="#" title="delete" ></a>
                    </div>
                    <div class="expanded">
                    <ul>
                        <li><label>Product:</label> {{g.product_name}}</li>
                        <li>
                            <label>Promoters: {{g.promoter.count}}</label><br/>
                            <ul>
                                {% for p in g.promoter %}
                                    <li>
                                        {{p}}
                                    </li>
                                {% endfor %}
                            </ul>
                        </li>
                    </ul>
                    </div>
                </li>
            {% endfor%}
            </ul>
            {%else%}
            <p>No genes</p>
            {%endif%}
            </div>
        </div>
    </div>
</li>
